from appium.webdriver.common.appiumby import AppiumBy as By
from pages.base_page import BasePage


# 定位器
cpllect_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("收藏")')
collect_recipe_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("所有菜谱")')
history_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("浏览历史")')
round_hollow_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/round_hollow").instance(0)')
description_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().description("编辑")')
tv_right_locator=(By.ID,'com.xiachufang:id/tv_right')
tv_delete_locator=(By.ID,'com.xiachufang:id/tv_delete')
tv_right_01_locator=(By.ID,'com.xiachufang:id/tv_right')
find_hot_recipe_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/recipe_visit_history_find_hot_recipe_btn")')


# 操作
class CollectHistoryPage(BasePage):
    """收藏历史页面"""
    def click_collect(self):
        """点击收藏"""
        self.find_element(cpllect_locator).click()

    def click_collect_recipe(self):
        """点击所有菜谱"""
        self.find_element(collect_recipe_locator).click()

    def click_history(self):
        """点击浏览历史"""
        self.find_element(history_locator).click()

    def click_round_hollow(self):
        """点击浏览历史中的菜谱"""
        self.find_element(round_hollow_locator).click()

    def click_description(self):
        """点击编辑"""
        self.find_element(description_locator).click()

    def click_tv_right(self):
        """点击全选"""
        self.find_element(tv_right_locator).click()

    def click_tv_delete(self):
        """点击删除"""
        self.find_element(tv_delete_locator).click()

    def click_tv_right_01(self):
        """点击确定删除"""
        self.find_element(tv_right_01_locator).click()

    def click_find_hot_recipe(self):
        """
        点击发现热菜
        :return:
        """
        el=self.find_element(find_hot_recipe_locator).text
        return el
